package com.neutech.neusys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neutech.neusys.mapper.ConsMapper;
import com.neutech.neusys.mapper.DeptMapper;
import com.neutech.neusys.mapper.RegistMapper;
import com.neutech.neusys.mapper.UserMapper;
import com.neutech.neusys.service.UserService;
import com.neutech.po.ConstantItem;
import com.neutech.po.Dept;
import com.neutech.po.RegistLevel;
import com.neutech.po.User;
import com.neutech.vo.ToAddUserVo;
@Service
public class UserServiceImpl implements UserService{
	@Autowired
	private UserMapper userMapper;
	@Autowired
	private DeptMapper deptMapper;
	@Autowired
	private RegistMapper registMapper;
	@Autowired
	private ConsMapper consMapper;
//	增加用户
//	@param：用户对象
//	@return：添加成功：1，添加失败：0
	@Override
	public int addUser(User user) {
		// TODO Auto-generated method stub
		int num = userMapper.addUser(user);
		return num;
	}
//	添加用户界面出现前，要查询信息，填充下拉列表
//	科室、用户类别、挂号级别、医生职称
//	@return：添加成功：1，添加失败：0
	@Override
	public ToAddUserVo toAddUser() {
		// TODO Auto-generated method stub
		List<Dept> deptList = deptMapper.queryAll();
		List<RegistLevel> regList = registMapper.queryAll();
		List<ConstantItem> docList = consMapper.docAll();
		List<ConstantItem> userList = consMapper.userAll();
		ToAddUserVo vo = new ToAddUserVo();
		vo.setDeptList(deptList);
		vo.setRegList(regList);
		vo.setDocList(docList);
		vo.setUserList(userList);
		return vo;
	}
	@Override
	public List<User> queryAllUser() {
		// TODO Auto-generated method stub
		return userMapper.queryAllUser();
	}
	@Override
	public User toupdateUserById(User user) {
		// TODO Auto-generated method stub
		return userMapper.toupdateUserById(user);
	}
	@Override
	public int updateUser(User user) {
		// TODO Auto-generated method stub
		return userMapper.updateUser(user);
	}

}
